/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package themsanpham;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.TextBox;
import javafx.scene.layout.HBox;
import themsanpham.ThongTinSanPhamClass;
import javafx.scene.text.Font;

/**
 * @author ToanNhan
 */
public class ThongTinSanPham extends CustomNode {

    public-init var TenTruong: String;
    public-init var GiaTri: String;
    public-init var X: Integer;
    public-init var Y: Integer;
    public-init var Width: Integer;
    protected var textBoxLabel: TextBox;
    protected var textBoxValue: TextBox;

    def contentWidth = Width / 2;
    def font: Font = Font.font("Arial", 12);
    protected override function create(): Node {
        return Group {
                    content: [
                        HBox{
                            spacing: 5;
                            content: [
                                textBoxLabel = TextBox{
                                    font: font
                                    layoutX: X layoutY: Y
                                    columns: bind contentWidth as Float
                                }
                                textBoxValue = TextBox{
                                    font: font
                                    layoutX: X layoutY: Y
                                    columns: bind contentWidth as Float
                                }
                                ]
                        }
                    ]
                }

    }

    public function xuatThongTinSanPham(): ThongTinSanPhamClass{
        var thongTin: ThongTinSanPhamClass = new ThongTinSanPhamClass();
            thongTin.setTenThonTin(textBoxLabel.text);
            thongTin.setGiaTri(textBoxValue.text);
        return thongTin;
    }



}
